package com.tms.quartz.service;

import org.quartz.JobDetail;
import org.quartz.SchedulerException;
import org.quartz.Trigger;

import java.util.List;
import java.util.Map;

/**
 * 夹具job服务类
 *
 * @author jackie
 * @date 2020年6月30日
 */
public interface JobService {

    /**
     * 添加一个job
     * @param clazz 对应的job类
     * @param jobName job名称
     * @param jobGroup job分组
     * @param param job参数
     * @return 成功返回建立的job
     * @throws SchedulerException scheduler异常
     */
    JobDetail addJob(Class clazz, String jobName, String jobGroup, Map<String, String> param) throws SchedulerException;

    /**
     * 暂停job
     * @param jobName job名称
     * @param jobGroup job分组
     * @return 成功返回true，失败返回false
     * @throws SchedulerException scheduler异常
     */
    boolean pauseJob(String jobName, String jobGroup) throws SchedulerException;

    /**
     * 恢复job
     * @param jobName job名称
     * @param jobGroup job分组
     * @return 成功返回true，失败返回false
     * @throws SchedulerException scheduler异常
     */
    boolean resumeJob(String jobName, String jobGroup) throws SchedulerException;

    /**
     * 删除job
     * @param jobName job名称
     * @param jobGroup job分组
     * @return 成功返回true，失败返回false
     * @throws SchedulerException scheduler异常
     */
    boolean removeJob(String jobName, String jobGroup) throws SchedulerException;

    /**
     * 返回job的triggers
     * @param jobName job名称
     * @param jobGroup job分组
     * @return job对应的triggers
     * @throws SchedulerException scheduler异常
     *
     */
    List<Trigger> viewTriggersJob(String jobName, String jobGroup) throws SchedulerException;

    /**
     * 启动所有定时任务
     */
    public void startAllJobs();

    /**
     * 关闭所有定时任务
     */
    public void shutdownAllJobs();
}
